//
//  HZEmoticonPageViewCell.swift
//  HansWeibo
//
//  Created by Hans on 16/8/18.
//  Copyright © 2016年 Hans. All rights reserved.
//

import UIKit

class HZEmoticonPageViewCell: UICollectionViewCell {
    
    var indexPath :NSIndexPath?{
        didSet{
            
            messageLabel.text = "第\(indexPath?.section ?? 0)组\n第\(indexPath?.item ?? 0)页"
        }
    }
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    private func setupUI(){
        backgroundColor = randomColor()
        // 添加控件
        addChildButton()
        contentView.addSubview(messageLabel)
        // 添加约束
        messageLabel.snp_makeConstraints { (make) in
            make.center.equalTo(self)
        }
        
    }
    // 创建20个按钮
    func addChildButton(){
        // 循环创建button
        for _ in 0..<HZEmticonsMaxCount {
            let button = UIButton()
            // 设置随机颜色
            button.backgroundColor = randomColor()
            // 添加按钮
            contentView.addSubview(button)
        }
    }
    
    //MARK: - 懒加载控件
    private lazy var messageLabel: UILabel = UILabel(textColor: UIColor.redColor(), textFont: 35, maxWidth: SCREENW)
    
}
